﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Android.App;
using Android.Content;
using Android.OS;
using Android.Runtime;
using Android.Views;
using Android.Widget;

namespace Medicine.Helpers
{
    public static class MessageShow
    {
        public static void ShowShortMsg(Context context, string message)
            => Toast.MakeText(context, message, ToastLength.Short).Show();

        public static void ShowLongMsg(Context context, string message)
            => Toast.MakeText(context, message, ToastLength.Long).Show();

        /// <summary>
        /// 一个显示简单弹窗的方法
        /// 弹窗有一个确定按钮
        /// </summary>
        /// <param name="context"></param>
        /// <param name="title">标题</param>
        /// <param name="message">消息</param>
        /// <param name="eventHandler">绑定确定按钮事件</param>
        public static void ShowNoticeMsg(Context context,
                                            string title,
                                            string message,
                                            EventHandler<DialogClickEventArgs> eventHandler = null)
        {
            Android.Support.V7.App.AlertDialog.Builder builder = new Android.Support.V7.App.AlertDialog.Builder(context);
            builder.SetMessage(message);
            builder.SetTitle(title);
            builder.SetNegativeButton("确定", eventHandler);

            builder.Create().Show();
        }

        /// <summary>
        /// 一个显示简单弹窗的方法
        /// 弹窗有一个确定按钮，一个取消按钮
        /// </summary>
        /// <param name="context"></param>
        /// <param name="title">标题</param>
        /// <param name="message">消息</param>
        /// <param name="eventHandler">绑定确定按钮事件</param>
        public static void ShowQuestionNoticeMsg(Context context,
                                            string title,
                                            string message,
                                            EventHandler<DialogClickEventArgs> eventHandler = null,
                                            EventHandler<DialogClickEventArgs> cancelEventHandler = null)
        {
            Android.Support.V7.App.AlertDialog.Builder builder = new Android.Support.V7.App.AlertDialog.Builder(context);
            builder.SetMessage(message);
            builder.SetTitle(title);
            builder.SetNegativeButton("确定", eventHandler);
            builder.SetNeutralButton("取消", cancelEventHandler);

            builder.Create().Show();
        }
    }
}